import basic from '../../../xc/model/basic.js';
var actmodel = new basic();
actmodel.do = "distribution_manage"
actmodel.distrmoneyoffset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["createtime", "desc"]] ;
  }
 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "distrmoneyoffset"
  }
  else {
    this.wherepara["op"] = "distrmoneyoffset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}

actmodel.applyform = function () {
  var app = getApp();
  var data = { "op": "applyform" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.gudongapply = function () {
  var app = getApp();
  var data = { "op": "gudongapply" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.addapply = function (model) {
  var app = getApp();
  var data = { "op": "addapply", xc: model }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
actmodel.centerinfo = function () {
  console.log("ntc")
  var app = getApp();
  var data = { "op": "centerinfo" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
actmodel.refreshmember = function () {
  console.log("ntc")
  var app = getApp();
  var data = { "op": "refreshmember" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.applystatus = function (that, actleadgroup,) {
  if (!actleadgroup) {
    actleadgroup = app.globalData.actleadgroup
  }
  if (!actleadgroup) {
    return false;
  }

  var widgetsapply = that.selectComponent("#widgetsapply")
  if (actleadgroup["islock"] == 1) {
    if (widgetsapply) {
      widgetsapply.showmodel("用户已经被锁定", "用户已经被锁定请联系管理员", 'warn', 'red')
    }
  }
  if (actleadgroup["autarky"] == 1 || actleadgroup["applystatus"] == 2) {
    return true
  }
  else {
    var app = getApp();
    var prothem = app.globalData.configdata.prothem.themcolor.config
    if (widgetsapply&&actleadgroup["applystatus"] == 1) {  
        widgetsapply.showmodel("正在审核中...", "请耐心等待，1-3个工作日完成审核", 'waiting', prothem.primarycolor)
      } else if (actleadgroup["applystatus"] == 3) {
        widgetsapply.showmodel("您的审核未通过.", "请完善咨询", 'warn', 'red')
      }
      else if (actleadgroup["applystatus"] == 4) {
        widgetsapply.showmodel("您的审核未通过.", "您的审核未通过.", 'warn', 'red')
      }    
  }
  return false
}

actmodel.getnotice = function () {
 
  var app = getApp();
  var data = { "op": "getnotice" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.getarea = function () {
  var app = getApp();
  var data = { "op": "getarea" }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
module.exports = actmodel;